<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	String path = request.getContextPath();
%>
<%@taglib prefix="shiro" uri="http://shiro.apache.org/tags" %>
<html>
<head>
<meta charset="UTF-8">
<meta name="copyright" content="Tencent" />
<meta name="keywords" content="" />
<meta name="description" content="" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="format-detection" content="telephone=no">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0,user-scalable=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<title>活动</title>
<link href="<%=path%>/favicon.ico" rel="shortcut icon">
<link href="https://cdn.jsdelivr.net/gh/bootcdn/BootCDN/ajax/libs/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/public.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/marketing.css" />
<link rel="stylesheet" type="text/css"
	href="<%=path%>/css/marketing/activity.css" />
	

</head>
<body class="s_activity_body">
    
    <div id="editor"></div>
	

	<div class="k_activity">
        <div id="button_info" >

        </div>
	</div>

	<ul class="s_footer">

	</ul>
	
	<div class="s_popup_delect2">
        <div class="s_consum">
            <p id="dialog_title"><img src="<%=path%>/images/marketing/s_tick.png" /> 活动启用成功</p>
        </div>
    </div>
	<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.4/jquery.min.js"></script>
	<script src="<%=path%>/js/marketing/swiper-3.2.7.min.js"></script>
	<script src="<%=path%>/js/marketing/jquery.iosslider.js"></script>
	<script src="<%=path%>/js/marketing/jquery.lt_slide.js"></script>
	<script>
	
	var model_id;
	var cid;
	
	
	
	    function keyPress() {    
	     var keyCode = event.keyCode;    
	     if ((keyCode >= 48 && keyCode <= 57))    
	     {    
	         event.returnValue = true;    
	        } else {    
	           event.returnValue = false;    
	        }    
	     } 

        
        //起始方法
		$(function() {
			getDetail(); 
		});

		
        //获取活动详情
		function getDetail() {
			model_id= getQueryString("model_id");
			cid=getQueryString("cid");
			console.log("model_id--------->"+model_id);
			console.log("cid--------->"+cid);
			var url="<%=path%>/activityDefinedTemplate/ajaxTemplateDetail";
			$.post(url, {
				"cid" : cid,
				"id" : model_id,
			}, function(data) {
				
				
				if (data.status == 200) {
					setHtml(data.data);
				} else {

				}
			});
		}
        
        
		//设置活动信息
		function setHtml(data) {
			$('#editor').html(data.text_info);
			$(document).attr("title",data.name);
			//設置提交信息按钮框
			var commit_info=data.collect_info.split(",");
			if(StringEmpty(commit_info)&&commit_info.length>0){
				var button_html='';
				for(var i=0;i<commit_info.length;i++){
					switch (commit_info[i]) {
					
					case "commit_name":
						
						button_html+='<br><br><div class="s_name_input"><i>姓名</i><input id="name_input" type="text" /></div>';
						break;
                    case "commit_mobile":
                    	button_html+='<div class="s_name_input"><i>电话</i><input id="mobile_input" type="text" style="ime-mode:disabled;" onkeypress="keyPress()" maxlength="11"/></div>';
						break;
					case "commit_email":
						email_flag=true;
						button_html+='<div class="s_name_input"><i>邮箱</i><input id="email_input" type="email" /></div>';
						break;
                    case "commit_weibo":
                    	weibo_flag=true;
                    	button_html+='<div class="s_name_input"><i>微博</i><input id="weibo_input" type="text" /></div>';
						break;
                    case "commit_weixin":
                    	weixin_flag=true;
                    	button_html+='<div class="s_name_input"><i>微信</i><input id="weixin_input" type="text" /></div>';
						break;
                    case "commit_job":
                    	job_flag=true;
                    	button_html+='<div class="s_name_input"><i>职位</i><input id="job_input" type="text" /></div>';
						break;
                    case "commit_company":
                    	company_flag=true;
                    	button_html+='<div class="s_name_input"><i>公司</i><input id="company_input" type="text" /></div>';
						break;
					default:
						break;
					}
				}
				button_html+='<div id="btn_join" class="s_get_btn">'+(data.button_text!=""? data.button_text:"立即领取")+' </div>';
				$('#button_info').html(button_html);
				
				if(StringEmpty(data.button_text))
					$(".s_get_btn").css("background-color",data.button_css);
			}else{
				
			}
				

			if(StringEmpty(data.weixin_qrcode)&&!StringEmpty(data.weibo_qrcode)){
				console.log("weixin--->");
				var html_weixin='<li style="width:100%"><img id="weixin_qrcode" src="'+data.weixin_qrcode+'" /><p>微信二维码</p></li>';
				$(".s_footer").append(html_weixin); 
			}else if(StringEmpty(data.weixin_qrcode)){
				var html_weixin='<li><img id="weixin_qrcode" src="'+data.weixin_qrcode+'" /><p>微信二维码</p></li>';
				$(".s_footer").append(html_weixin); 
			}
			
            if(StringEmpty(data.weibo_qrcode)&&!StringEmpty(data.weixin_qrcode)){
            	console.log("weibo_qrcode");
            	var html_weibo='<li style="width:100%"><img id="weibo_qrcode" src="'+data.weibo_qrcode+'" /><p>微博二维码</p></li>';
				$(".s_footer").append(html_weibo); 
			}else if(StringEmpty(data.weibo_qrcode)){
				var html_weibo='<li><img id="weibo_qrcode" src="'+data.weibo_qrcode+'" /><p>微博二维码</p></li>';
				$(".s_footer").append(html_weibo); 
			}
		}
	
		
		   //获取url的参数
		function getQueryString(name) {
			var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
			var r = window.location.search.substr(1).match(reg);
			if (r != null)
				return unescape(r[2]);
			return null;
		}
		//判断字符串是否为空
		function StringEmpty(content) {
			if (content == undefined || content == "" || content == null) {
				return false;
			} else {
				return true;
			}
		}
	</script>


</body>
</html>